package com.wwg.cms.freemarker;

import com.css.framework.container.Container;
import freemarker.core.Environment;
import freemarker.template.*;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 *
 * @author 王文磊
 * @version $Id: CallService.java 16 2010-08-30 07:15:17Z sanshi2 $
 * @date 2010-8-16 14:18:33
 */
public class CallService implements TemplateDirectiveModel {
    public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {

        List list = new ArrayList();
//        list.add("dddddddddd");
//        list.add("sssssss");
//        list.add("ggggggggg");
        String serviceid= (String) params.get("serviceid");
        String serviceClass= (String) params.get("serviceClass");
        String methodNmae= (String) params.get("method");
        Object prs=params.get("params");
        Object[] myparams=null;
        if(prs==null){
            myparams=new Object[0];
        }
        //else if(prs instanceof )
        Class aClass=null;
        try{
            aClass=Class.forName(serviceClass==null?serviceid:serviceClass);
          Object sO=  Container.getServiceFromBroker(serviceid,aClass);
          // String method=aClass.getMethod("");
        } catch (Exception e) {
        }

        for (int i = 0; i < list.size(); i++) {
            String s = (String) list.get(i);
            env.setCustomAttribute("id",i);
            env.setCustomAttribute("this",s);
            env.getTemplate();
            if (body != null)
                body.render(env.getOut());

        }

    }
}
